<template>
  <el-dialog title="发货信息" :visible="visible" destroy-on-close @close="onVisibleChange">
    <el-form :model="form" :rules="rules">
      <el-row :gutter="20">
        <el-col :span="16">
          <el-form-item label="运单编号" prop="express_number">
            <el-input v-model="form.express_number" autocomplete="off" size="small" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="承运公司" prop="express_company">
            <el-select v-model="form.express_company" placeholder="请选择承运公司" size="small">
              <el-option
                v-for="item in list"
                :key="item.code"
                :label="item.name"
                :value="item.code"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="备注" prop="comments">
        <el-input
          v-model="form.comments"
          placeholder="请输入"
          type="textarea"
          :rows="4"
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="onVisibleChange">取 消</el-button>
      <el-button type="primary" @click="handlePost">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'OrderAction',
  props: {
    visible: {
      type: Boolean,
      default: false,
      required: true
    },
    list: {
      type: Array,
      default: () => {
        return []
      },
      required: true
    }
  },
  data() {
    return {
      form: {},
      rules: {
        express_number: [{ required: true, message: '运单号不能为空', trigger: 'blur' }],
        express_company: [{ required: true, message: '承运公司不能为空', trigger: 'blur' }]
      }
    }
  },
  methods: {
    handlePost() {
      this.$emit('fall-back', this.form)
    },
    onVisibleChange() {
      this.$emit('on-visible-change', false)
    }
  }
}

</script>
